#include "gtest/gtest.h"

#define private public
#define protected public

#include <iostream>
#include "String.hh"


class String_unittest:public testing::Test{
	


} ;

TEST_F(String_unittest, DefaultConstructor) {
	//std::string h1="hahahahah";
	mtool::String S1="hahahahah";
  	EXPECT_EQ(S1.size(), 9);
	std::string s1="hahahahah";
	int c=S1.compare(s1);
  	EXPECT_EQ(c, 0);
	int c1=s1.compare(S1);
  	EXPECT_EQ(c1, 0);
	
}

TEST_F(String_unittest, ltrim) {
	mtool::String S1="     1234567890   ";
	S1.ltrim();
  	EXPECT_STREQ(S1.c_str(), "1234567890   ");
  	EXPECT_EQ(S1.size(), 13);

	mtool::String S2="abcdefg";
	S2.ltrim();
  	EXPECT_EQ(S2.size(), 7);

}

TEST_F(String_unittest, rtrim) {
	mtool::String S1="     1234567890   ";
	S1.rtrim();
  	EXPECT_STREQ(S1.c_str(), "     1234567890");
  	EXPECT_EQ(S1.size(), 15);
}
  
TEST_F(String_unittest, trim) {
	mtool::String S1="     1234567890   ";
	S1.trim();
  	EXPECT_EQ(S1.size(), 10);
}


TEST_F(String_unittest, casecompare) {
	mtool::String S1="abcdefg";
	int iret=S1.casecompare("AbcdEFG");
  	EXPECT_EQ(iret, 0);
}


TEST_F(String_unittest, testmap) {
	const char * str="wxd18";
	mtool::StringRef k1(str,3);
	mtool::StringRef v1(str+3,2);
	std::map<mtool::StringRef,mtool::StringRef> ma;
	
}

